<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/decorators/taglibs.jsp"%>
<div class="w1a">
<div class="w2">個人資料 » 密碼修改</div>
<form:form modelAttribute="personal" id="personal">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width="80" align="right">姓名：</td>
			<td style="padding:5px;">${personal.name }</td>
	    </tr>
	    <tr>
			<td width="80" align="right">帳號：</td>
			<td style="padding:5px;">${personal.userName }</td>
	    </tr>
		<tr>
			<td width="80" align="right">新密碼：</td>
			<td style="padding:5px;"><form:password required="true" class="easyui-validatebox" validType="length[8, 16]" style="width:200px" id="password" path="password" /></td>
	    </tr>
	    <tr>
			<td width="80" align="right">確認密碼：</td>
			<td style="padding:5px;"><input type="password" validType="equalTo['#password']" required="true" class="easyui-validatebox" style="width:200px" id="password2" name="password2" /></td>
	    </tr>
		<tr>
			<td colspan="2">
				<a href="#do" class="easyui-linkbutton" onClick="update();">送出</a>
			</td>
		</tr>
	</table>			
</form:form>
</div>
<script>  
/*必须和某个字段相等*/
$.extend($.fn.validatebox.defaults.rules, {  
    equalTo: {validator:function(value,param){ return $(param[0]).val() == value; }, message:'密碼不相同' }    
});
function update(){
	if( $("#personal").form('validate') ){
		$.post("${appPath}/personal/password/update.json", {password:$("#password").val()},
	   			function(data) {
	        	console.log(data);
	   				if (eval(data)) {
	   					alert("更新成功!");
	   				} else {
	   					alert("更新失敗!");
	   				}
	   		});
	}
}
</script>